package ru.jexp.rcp.supply.n.commands.state;

import org.eclipse.ui.services.IServiceLocator;

public abstract class AJExpProviderState implements JExpProviderState
{
	private JExpSourceProviderStateFactory sourceProvider;
	
	private boolean enabled;
	
	public AJExpProviderState()
	{
	}
	
	public void setSourceProvider(JExpSourceProviderStateFactory sourceProvider)
	{
		this.sourceProvider = sourceProvider;
		setDefaultEnabledSate();
	}
	
	protected void setDefaultEnabledSate()
	{
		setEnabled(false);
	}

	@Override
	public void initialize(IServiceLocator locator)
	{
	}
	
	public void setEnabled(boolean enabled)
	{
		this.enabled = enabled;
		sourceProvider.enabledChanged(getPriorityLevel(), getSourceName(), enabled);
		
	}
	
	@Override
	public boolean isEnabled()
	{
		return enabled;
	}

}
